<template>
  <view class="container-white">
    <image class="head-img" src="../../static/img/mistakes-img.png" />
    <view class="list">
      <view class="list-cell flex-box" @click="goExamList(1,errorCount.integerZS)">
        <view class="list-cell-name">正式考试</view>
        <view class="flex-box">
          <view class="list-cell-num">{{errorCount.integerZS?errorCount.integerZS:'0'}} 道</view>
          <image src="../../static/icon/icon-go.png" class="icon-go" />
        </view>
      </view>
      <view class="list-cell flex-box" @click="goExamList(2,errorCount.integerMN)">
        <view class="list-cell-name">模拟考试</view>
        <view class="flex-box">
          <view class="list-cell-num">{{errorCount.integerMN?errorCount.integerMN:'0'}} 道</view>
          <image src="../../static/icon/icon-go.png" class="icon-go" />
        </view>
      </view>
      <view class="list-cell flex-box" @click="goTopic(4,errorCount.integerMR)">
        <view class="list-cell-name">每日一题</view>
        <view class="flex-box">
          <view class="list-cell-num">{{errorCount.integerMR?errorCount.integerMR:'0'}} 道</view>
          <image src="../../static/icon/icon-go.png" class="icon-go" />
        </view>
      </view>
      <view class="list-cell flex-box" @click="goExamList(3,errorCount.integerSW)">
        <view class="list-cell-name">三违考试</view>
        <view class="flex-box">
          <view class="list-cell-num">{{errorCount.integerSW?errorCount.integerSW:'0'}} 道</view>
          <image src="../../static/icon/icon-go.png" class="icon-go" />
        </view>
      </view>
      <view class="list-cell flex-box" @click="goTopic(5,errorCount.integerZY)">
        <view class="list-cell-name">专业提升</view>
        <view class="flex-box">
          <view class="list-cell-num">{{errorCount.integerZY?errorCount.integerZY:'0'}} 道</view>
          <image src="../../static/icon/icon-go.png" class="icon-go" />
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import {post_md5} from '../../common/request'

export default {
  data() {
    return {
      errorCount: {}
    }
  },
  onShow() {
    this.getErrorCount()
  },
  methods: {
    getErrorCount() {
      const params = {
        userId: uni.getStorageSync('userId')
      }
      post_md5('/exam-app/error/quescount', params).then(res => {
        console.log(res.data)
        this.errorCount = res.data
      })
    },
    goExamList(val, num) {
      if (num > 0) {
        uni.navigateTo({
          url: '../mistakes/exam-list?examType=' + val
        })
      } else {
        uni.showToast({
          title: '该分类暂无错题',
          icon: 'none'
        })
      }
    },
    goTopic(examType, val) {
      if (val > 0) {
        uni.navigateTo({
          url: 'mistake-topic?examType=' + examType
        })
      } else {
        uni.showToast({
          title: '本分类暂无错题',
          icon: 'none'
        })
      }
    }
  }
}
</script>

<style>
.head-img {
  width: 100%;
  height: 449upx;
}

.list-cell {
  border-bottom: 1px solid #e6e6e6;
  padding: 36upx 20upx;
}

.list-cell-name {
  margin-left: 60upx;
  width: 118px;
  font-size: 30upx;
  color: #333333;
}

.list-cell-num {
  font-size: 24upx;
  color: #666666;
}

.icon-go {
  width: 14upx;
  height: 24upx;
  margin-left: 10upx;
}
</style>
